Skip to content

fix(openai/0.x): handle OpenRouter image generation responses#8880

Merged
Christian Bromann (christian-bromann) merged 2 commits into
mainfrom
cb/openai-router-image-response-support-v0.x
Sep 9, 2025
Merged

fix(openai/0.x): handle OpenRouter image generation responses#8880
Christian Bromann (christian-bromann) merged 2 commits into
mainfrom
cb/openai-router-image-response-support-v0.x

Conversation

@christian-bromann
Copy link
Copy Markdown
Member

backported from #8879

- Add support for OpenRouter's image generation API response format
- Extract images from OpenRouter's `choices[0].message.images` array
- Convert images to LangChain's Multimodal.Image content blocks
- Add unit tests for single image, multiple images, and text-only responses
- Use proper TypeScript types for content blocks

OpenRouter returns generated images in a separate `images` array rather than
within the message content. This fix ensures these images are properly
extracted and converted to LangChain's standard multimodal message format.

Fixes: #8791
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Sep 8, 2025

⚠️ No Changeset found

Latest commit: 13603a9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented Sep 8, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
langchainjs-docs Ready Ready Preview Comment Sep 9, 2025 5:35pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
langchainjs-api-refs Ignored Ignored Sep 9, 2025 5:35pm

@christian-bromann Christian Bromann (christian-bromann) changed the title fix(openai): handle OpenRouter image generation responses fix(openai/0.x): handle OpenRouter image generation responses Sep 8, 2025
@vercel vercel Bot temporarily deployed to Preview – langchainjs-docs September 9, 2025 00:02 Inactive
Copy link
Copy Markdown
Member

@hntrl Hunter Lovell (hntrl) left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everything but the standard type change should be relevant for this PR also:

#8879 (review)

@christian-bromann
Copy link
Copy Markdown
Member Author

Updated PR in the same way as #8879

@vercel vercel Bot temporarily deployed to Preview – langchainjs-docs September 9, 2025 17:35 Inactive
@christian-bromann Christian Bromann (christian-bromann) merged commit 76400ae into main Sep 9, 2025
36 checks passed
@christian-bromann Christian Bromann (christian-bromann) deleted the cb/openai-router-image-response-support-v0.x branch September 9, 2025 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants